package com.hmall.domain.utils;

/**
 * 本地线程共享工具类
 *
 * @Author XiaoJiangShi
 * @Date 2022/8/11 18:06
 * @Blog blog.XiaoJiangShi.net/996.mba
 * @Description: 本地线程工具类
 */
public class ThreadLocalUtil {
    private static final ThreadLocal<Long> THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置id值
     *
     * @param id 共享的id值
     */
    public static void setId(String id) {
        THREAD_LOCAL.set(Long.parseLong(id));
    }

    /**
     * 获取id值
     *
     * @return 返回id
     */
    public static String getId() {
        return THREAD_LOCAL.get().toString();
    }

    /**
     * 释放资源
     */
    public static void remove() {
        THREAD_LOCAL.remove();
    }

}

